package com.aikon.wht;

import com.aikon.wht.Environment.BaseEnvironment;
import com.aikon.wht.properties.OtherProperties;
import com.aikon.wht.service.BaseService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ExitCodeGenerator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.Ordered;
import org.springframework.core.convert.support.ConfigurableConversionService;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MissingRequiredPropertiesException;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.Map;

/**
 * Created by haitao.wang on 2016/12/8.
 */
@EnableAutoConfiguration
@Configuration
@ComponentScan
//@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan
@EnableConfigurationProperties(OtherProperties.class)
//@Profile("test")  //Any @Component or @Configuration can be marked with @Profile to limit when it is loaded.
@EnableScheduling
public class HelloWorld
        implements Ordered,ExitCodeGenerator
{


    /*Ways 2 run*/
    /*mvn spring-boot:run*/
    /*spring run HelloWorld.java*/
    /*java -jar ./target/springbootstarter-1.0-SNAPSHOT.jar --debug (Enable AutoConfigurationReportLoggingInitializer)*/
    /*java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n \
            -jar ./target/springbootstarter-1.0-SNAPSHOT.jar*/


    public static void main(String[] args) {

//        Ways to bootstrap the application

        SpringApplication application = new SpringApplication(HelloWorld.class);
        application.run(args);

//        new SpringApplicationBuilder()
//                .sources(HelloWorld.class)
////                .child(FirstChildConfig.class)
//                .run(args);

//        SpringApplication.run(HelloWorld.class, args);
    }

    @Override
    public int getOrder() {
        return 0;
    }

    @Override
    public int getExitCode() {
        return 10000;
    }
}
